package com.qp;

import com.qp.opc.OpcUaClientFacade;
import com.qp.opc.OpcUaClientFactory;
import com.qp.opc.OpcUaConfig;
import com.qp.opc.OpcUaUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Set;

public class OpcRead1C {
    //日志
    private static final Logger log = LoggerFactory.getLogger(OpcUaClientFactory.class);

    public static void main(String[] args) {
//        OpcUaConfig opcConfig = new OpcUaConfig().setUrl("opc.tcp://192.168.155.103:49320");
        OpcUaConfig opcConfig = new OpcUaConfig().setUrl("opc.tcp://127.0.0.1:49320");
        OpcUaClientFacade client;
        try {
            client = OpcUaClientFactory.getClient(opcConfig);
        } catch (Exception ex) {
            ex.printStackTrace();
            return;
        }
        try {
            Set<String> names = OpcUaUtil.browse(client, "Channel_SWL.DeviceSWL.OP085");
            for (String name : names) {
                System.out.println(name);
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
//
//        try {
//            String key = "Jiao_Mokuai_PLC.Jiao_Mokuai_Product.Ms-Zs_Data_20";
//            Object flag = OpcUaUtil.readValue(client,key);
//            System.out.println(flag);
//        } catch (Exception ex) {
//            log.error(ex.getMessage(), ex);
//        }
    }
}